@extends('layout.adminlayout')
@section('css')
 <script src="/admin/js/metisMenu.min.js"></script>
 <script src="/admin/js/custom.js"></script>
 <link href="/admin/css/custom.css" rel="stylesheet">
 <link href="/admin/css/add_manage.css" rel="stylesheet">
@endsection
@section('content')
<div class="forms">
      <div class=" form-grids row form-grids-right"> 
       <div class="widget-shadow " data-example-id="basic-forms"> 
        <div class="form-title"> 
         <h4>区域编辑 :</h4> 
        </div> 
        <div class="form-body"> 
         <form action="public/admin/area/create" method="post" class="form-horizontal">
          {{csrf_field()}}
          <div class="form-group"> 
           <label for="inputEmail3" class="col-sm-2 control-label" style="margin-left: -12px;top: 25px;    width: 33%;"> 区域名称 : </label> 
           <div class="col-sm-9"> 
            <input type="text" class="form-control" name="area_name" placeholder="区域名称" id="area_name" style="float: right;margin-right:-5px;" value="{{$data['a_name']}}"/>
            <input type="hidden" name="" id="a_id" value="{{$data['a_id']}}">
           </div>
          </div> 
          <div class="form-group"> 
           <label for="inputPassword3" class="col-sm-2 control-label"> </label> 
           <ul id="ul">
            @if($data['mma_username'] != '')
             @foreach($data['mma_username'] as $v)
              <li><div class="a">&nbsp;<span class="mng">{{$v}}</span>&nbsp;<img src="/admin/images/error1.png" alt="" class="img">&nbsp;</div></li>
             @endforeach
            @endif
           </ul> 
          </div> 
          <div class="form-group"> 
           <label for="inputPassword3" class="col-sm-2 control-label" id="fyt" style="margin-left: -12px;top: 26px;width: 33%;"> 负责人 : </label> 
           <div class="col-sm-9"> 
            <input type="text" class="form-control" name="manage" placeholder="管理员名称" id="manage" style="width: 45%; float: left top: 9px; margin-left: 6px;" />
            <button type="button" class="btn btn-default" id="add" style="float: right;margin-top: -34px;">添加</button> 
           </div> 
          </div> 
          <div class="col-sm-offset-2"> 
           <!-- <input type="submit" class="btn btn-default" value="Submit"> --> 
           <button type="button" class="btn btn-default" id="sub" style="margin-left:-43px; width:90%">提交</button> 
          </div> 
         </form> 
        </div> 
       </div> 
      </div> 
     </div> 
<script>
    //提交表单
  $('#sub').click(function () {
      var a_id = $('#a_id').val();
      var area_name = $('#area_name').val();
      var manage = new Array();
    $('.mng').each(function () {
       manage.push($(this).html());
        });
    if(area_name !=''){
            $.ajax({
                type:'post',
                url:'/admin/area/edit',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
          'a_id':a_id,
                    'area_name':area_name,
                    'manage':manage
                },
                dataType:'json',
                success:function (data) {
          location.href = '/admin/area/index';
                }
            })
    }else{
        alert('请填写区域名称')
            return false;
    }
    });
</script>
<script src="/admin/js/add_manage.js"></script>
@endsection